//
//  FQDColumnArticleFeedCellItemProvider.m
//  FakeQDaily
//
//  Created by mewxiv on 8/30/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDColumnArticleFeedCellItemProvider.h"
#import "FQDRegularFeedCellItem.h"
#import "QDailyAPI.h"
#import "FQDRestModel.h"

#import "YYModel.h"

static NSString *const kColumnArticleFeed = @"column_article";

@interface FQDColumnArticleFeedCellItemProvider ()
@property (nonatomic, strong) NSArray *response_feeds;
@end

@implementation FQDColumnArticleFeedCellItemProvider

- (void)getCellItems:(NSString *)cursorKey completion:(QDailyAPICompleteBlock)completion
{
    [[QDailyAPI sharedAPI] getColumnFeed:self.feedId key:cursorKey completion:completion];
}
// 解析feed响应数据
- (void)parseResponse:(id)response isLatest:(BOOL)isLatest
{
    self.response_feeds = [NSArray yy_modelArrayWithClass:[FQDFeed class]
                                                     json:response[@"feeds"]];
}

- (void)populateNewCellItemsTo:(NSMutableArray *)originalCellItems
{
    for (FQDFeed *feed in self.response_feeds) {
        FQDRegularFeedCellItem *cellItem = [FQDRegularFeedCellItem cellItemWithRestModel:feed];
        [originalCellItems addObject:cellItem];
    }
}

// 缓存id，如果为nil表示不缓存feeds，默认为nil
- (NSString *)cacheId
{
    return kColumnArticleFeed;
}

@end
